package com.imooc.annotationAccount.service;

import com.imooc.annotationAccount.dao.AccountDao;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: nettydemo
 * @description:
 * @author: jason.jia
 * @create: 2018-07-03 18:48
 **/

/**
 * propagation     :事务的传播行为。
 * isolation       :事务的隔离级别。
 * readOnly       :只读
 * rollbackFor    :发生哪些异常回滚事务
 * noRollbackFor ：发生哪些异常事务不回滚
 */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
public class AccountServiceImpl implements AccountService {

    private AccountDao accountDao;

    @Override
    public void transfer(String out, String in, Double money) {
       accountDao.inMoney(in, money);
       int a = 1/0;
       accountDao.outMoney(out, money);
    }

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }
}
